home *** CD-ROM | disk | FTP | other *** search
/ Softwarová Záchrana 3 / Softwarova-zachrana-3.bin / TextHarvest / TextHarvest-Install.exe / {app} / ScriptSample03.txt < prev    next >
Text File  |  2004-12-02  |  5KB  |  97 lines

  1. ;---------------------------------------------------------------------------
  2. ; Sample Parse-O-Matic Script for TextHarvest
  3. ;---------------------------------------------------------------------------
  4. ;
  5. ;   This script processes the input file InputSample01.txt, which is a
  6. ;   report of items sold.  (If you view the input file in the file viewer,
  7. ;   you will have to set the display width to 150 to see the lines without
  8. ;   their getting line-wrapped.)
  9. ;
  10. ;---------------------------------------------------------------------------
  11. ; Check settings. Please see the script file ScriptSample01.txt if you do
  12. ; not understand how this section works; the techniques are explained there.
  13. ;---------------------------------------------------------------------------
  14. Begin FirstLine = ''
  15.   FirstLine = 'N'
  16.   InputFileWanted = 'InputSample01.txt'
  17.   X = Len $OptionX $OptionY $OptionZ
  18.   Begin X <> 0
  19.     M1 = 'Please clear the /Keep /Delete and' $0A$0D
  20.     M2 = '/Control input boxes and try this'  $0A$0D
  21.     M3 = 'this script again.'
  22.     Stop M1 M2 M3
  23.   End
  24.   Begin $ActualIFN ~ InputFileWanted
  25.     M1 = 'Please try this script with the' $0A$0D
  26.     M2 = 'input file ' InputFileWanted
  27.     Stop M1 M2
  28.   End
  29.   ;
  30.   ;   Output header
  31.   ;
  32.   SepLine = Padded '' 80 'Left' '-'
  33.   OutEnd SepLine
  34.   X = 'Number of Items Sold to Each Customer'
  35.   X = Padded X 80 'Center'
  36.   OutEnd X
  37.   OutEnd SepLine
  38.   ;
  39.   ;   Output the date (which is on the first line of the input file)
  40.   ;
  41.   Date = $OutData[7 17]
  42.   OutNull                                   ; Skip a line
  43.   X = Padded Date 80 'Center'               ; Center the date
  44.   OutEnd X                                  ; Output the date
  45.   Done                                      ; Skip the rest of the script
  46. End
  47.  
  48. ;---------------------------------------------------------------------------
  49. ; Detect customer information line. We do this by looking for a digit in
  50. ; column 8.  The customer information line is the only line that has a digit
  51. ; there.
  52. ;---------------------------------------------------------------------------
  53. Begin '0123456789' ^ $OutData[8]            ; Look for the digit
  54.   CustName = $OutData[17 47]                ; Get the name
  55.   TrimChar CustName                         ; Remove the extra spaces
  56.   CustName = ChangeCase CustName 'HardCaps' ; Convert To Capital Letters
  57.   Change CustName '''S' '''s'               ; Fix case on possessives
  58.   X = Len CustName                          ; Find out how long it is
  59.   SepLine  = Padded '' X 'Left' '-'         ; A line as long as the name
  60.   SepLine  = Padded SepLine  80 'Center'    ; Center the line
  61.   CustName = Padded CustName 80 'Center'    ; Center customer name
  62.   OutNull                                   ; Skip a line
  63.   OutEnd SepLine                            ; Output the separator line
  64.   OutEnd CustName                           ; Output customer name
  65.   OutEnd SepLine                            ; Output the separator line
  66.   OutNull                                   ; Skip a line
  67.   Done                                      ; Skip the rest of the script
  68. End
  69.  
  70. ;---------------------------------------------------------------------------
  71. ; Detect the first line of the product information. We can recognize these
  72. ; because they always has a product code with the pattern AAA-NN-AAA (for
  73. ; example, ABC-12-XYZ) in columns 10 to 19.
  74. ;---------------------------------------------------------------------------
  75. TestCode = $OutData[10 19]                  ; Get what might be the code
  76. KeepChar TestCode '/AZ/09/-'                ; Remove any non-code characters
  77. ProdLine1 = 'Yes'                           ; Assume it's good for a moment
  78. If TestCode[4] <> '-' ProdLine1 = ''        ; We should have a dash in col 4
  79. If TestCode[7] <> '-' ProdLine1 = ''        ; We should have a dash in col 7
  80. Begin ProdLine1 = 'Yes'
  81.   ProdLine1 = ''                            ; Reset this back to null
  82.   NumberSold = $OutData[55 58]              ; Get number of units sold
  83.   ProdLine2 = 'Yes'                         ; Set up for next line of data
  84.   Done                                      ; Skip the rest of the script
  85. End
  86.  
  87. ;---------------------------------------------------------------------------
  88. ; If ProdLine2 = 'Y' it means that the previous line of data was the first
  89. ; line of product information.
  90. ;---------------------------------------------------------------------------
  91. Begin ProdLine2 = 'Yes'
  92.   ProdLine2 = ''                            ; Reset this back to null
  93.   Product = $OutData[10 40]                 ; Get product name
  94.   Product = Padded Product 54 'Left'        ; Put some spaces on the left
  95.   OutEnd Product NumberSold                 ; Output product and number sold
  96. End
  97.